*************************************************
********Regional Level Analysis******************
*************************************************

* directory definitions 
	
	project, doinfo
	global pdir "`r(pdir)'"							// the project's main dir.
	global dofile "`r(dofile)'"						// do-file's stub name
	global data_original = "$pdir/data_original"  //data directory for coded data 
	global data_coded = "$pdir/data_coded"  //data directory for coded data 
	global figures = "$pdir/results/figures"  //data directory for figures
	global tables = "$pdir/results/tables"  //data directory for tables

* 
	// report any data we create previously and we do need here: 
	project, uses("$data_coded/placebased_regional.dta")
	project, uses("$data_coded/placebased_mapdata.dta")
	project, uses("$data_coded/placebased_independence.dta")
	project, uses("$data_coded/placebased_individual.dta")


***MAINBODY***

* description:

	// map of m5s activity (fig 2)
	use "$data_coded/placebased_m5s_mapdata.dta", clear 
	spmap treated using "$data_coded/itcoord", id(id) ///
	ocolor(white ..) osize(none ..) ///
	fcolor(uzhblue uzhorange) legend(off)
	** save as pdf: 
	graph export "$figures/fig2b_m5s_activity.pdf", replace


* open regional level data for analysis below:

	use "$data_coded/placebased_regional.dta", clear 



	// histogram (fig 4)
	summarize referendum_no if m5s_ref_ever==0
	local m_control=r(mean)
	summarize referendum_no if m5s_ref_ever==1
	local m_treat=r(mean)

	histogram referendum_no if m5s_ref_ever==0, ///
	col(uzhblue%50) xtitle(% No in referendum) legend(order(1 "No M5S grassroots" 2 "M5S grassroots")) ///
	addplot(histogram referendum_no if m5s_ref_ever==1, col(uzhred2%50))  ///
	xline(`m_control', lcol(uzhblue)) xline( `m_treat', lcol(uzhred2)) ///
	text(-0.0006 59 "59", place(w) col(uzhblue) size(small)) text(-0.0006  62 "62", place(e) col(uzhred2) size(small))
	***save as pdf: 
	graph export "$figures/fig4_bivariatescatter.pdf", replace




* estimation:
	
	// define locals: 
	local controls m5s_c_13 pd_c_13 turnout_13 income unemployment university no_edu foreigners pop_density_16
	
	// OLS estimates (tab 1):
	eststo clear
	eststo: reghdfe referendum_no m5s_ref_ever, noabsorb cluster(province_id)
	eststo: reghdfe referendum_no m5s_ref_ever, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no m5s_ref_ever `controls', absorb(province_id)  cluster(province_id) 
	ebalance m5s_ref_ever `controls'
	reghdfe referendum_no m5s_ref_ever `controls' [aweight=_webal], absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no m5s_ref_ever [aweight=_webal], absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_treat_campaign, noabsorb cluster(province_id)
	eststo: reghdfe referendum_no std_wn_treat_campaign, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no std_wn_treat_campaign `controls', absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_treat_campaign [aweight=_webal], absorb(province_id)  cluster(province_id) 	
	** create a LaTeX Table:
	estfe est*, labels(province_id "Province FE")	
	** save the table:
	esttab est* using "$tables/tab1_ols_regional.tex", replace  ///
	indicate( `r(indicate_fe)' "Controls=income", labels(\checkmark)) ///
	se nobaselevels nostar label se(2) b(2) ///
	drop(pd_c_13 turnout_13 unemployment university no_edu foreigners pop_density_16) ///
	stats(N N_clust r2_a r2_a_within rmse, fmt(%9.0f %9.0f %9.2f %9.2f %9.2f)  labels("Obs" "Provinces" "adj.R\$^2$" "adj.R\$^2$ (within)" "RMSE")) ///
	note("\emph{Note:} Clustered standard errors by province in parentheses. Controls omitted from table: PD: \% votes 2013, \% turnout 2013, income per cap, \% unemployed, \% university degree, \% low education, \% foreigners, population density. Same variables used for matching, history omitted from matching.") ///
	substitute(_ _) 
	
	// one town simulation: 100 inhabitants, 0 vs 1 event, 10% rsvp
	reghdfe referendum_no std_wn_treat_campaign [aweight=_webal], absorb(province_id)  cluster(province_id) 
	dis log((5*10/100)+1)
	margins, at(std_wn_treat_campaign=(0 .40546511))
	dis  61.48344 -  61.41139
	* 0.06543
	margins, at(std_wn_treat_campaign=(0.95 1.79))

	// balance figure (fig 5)
	** standardize variables
	standard2 `controls'
	** produce balance figures: 
	eststo clear 
	foreach var of varlist std_m5s_c_13 std_pd_c_13 std_turnout_13 std_income std_unemployment std_university std_no_edu std_foreigners std_pop_density_16 {
		rename  m5s_ref_ever `var'_treat
		eststo raw_`var': reg `var' `var'_treat 
		rename  `var'_treat m5s_ref_ever 
	}
	foreach var of varlist std_m5s_c_13 std_pd_c_13 std_turnout_13 std_income std_unemployment std_university std_no_edu std_foreigners std_pop_density_16 { 
		rename  m5s_ref_ever `var'_treat
		eststo wgt_`var': reg `var' `var'_treat [aweight=_webal]
		rename  `var'_treat m5s_ref_ever 
	}
	** coefplot figure: 
	coefplot ///
	(raw_*) ///
	(wgt_*, msymbol(D)) ///
	, keep(*treat) xline(0) ///
	ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) ///
	legend(order(2 "raw" 4 "entropy balanced")) ///
	xtitle("standardized {it:differences} in means") ///
	grid(none) ///
	ylabel( ///
	1 "% M5S vote 2013" ///
	2 "% PD vote 2013" ///
	3 "% turnout 2013" ///
	4 "income per capita" ///
	5 "% unemployment" ///
	6 "% university degree" ///
	7 "% no education" ///
	8 "% foreigners" ///
	9 "population density" ///
	) 
	** save as pdf: 
	graph export "$figures/fig5_balance.pdf", replace

	// local vs. adjacent (fig 6a)
	eststo clear 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign if std_wn_treat_campaign==0, absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign `controls' if std_wn_treat_campaign==0, absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_treat_campaign std_wn_neigh_treat_campaign, absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_treat_campaign std_wn_neigh_treat_campaign `controls', absorb(province_id)  cluster(province_id) 
	** coefplot:
	coefplot ///
	est1 ///
	est2 ///
	(est3, msymbol(S)) ///
	(est4, msymbol(S)) ///
	, keep(std_wn_treat_campaign std_wn_neigh_treat_campaign) ///
	xline(0) ///
	legend(order(2 "only neighbouring" 4 "+ controls" 6 "neighbouring & local" 8 "+ controls")) ///
	xtitle("OLS coefficient of [...] on {bf:Referendum: No}") ///
	ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) ///
	title("{bf:A) local spillovers}") ///
	ylabel( ///
	1 "M5S: neighbouring activity cont." ///
	2 "M5S: activity cont." ///
	)
	** save as pdf: 
	graph export "$figures/fig6a_spillover_regional.pdf", replace

	// bystander effect indoor vs. outdoor (fig 7a + tab a11)
	** open regional level data:
	use "$data_coded/placebased_regional.dta", clear 
	** estimate: 
	eststo clear
	eststo: reghdfe referendum_no std_wn_treat_loc_indoor m5s_c_13 pd_c_13 turnout_13 income unemployment university no_edu foreigners pop_density_16, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no std_wn_treat_loc_outdoor m5s_c_13 pd_c_13 turnout_13 income unemployment university no_edu foreigners pop_density_16, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no std_wn_treat_loc_indoor std_wn_treat_loc_outdoor m5s_c_13 pd_c_13 turnout_13 income unemployment university no_edu foreigners pop_density_16, absorb(province_id) cluster(province_id)
	** open individual level panel data:
	use "$data_coded/placebased_individual.dta", clear 
	xtset 
	eststo: reghdfe referendum_no_wunsure std_wave_wn_treat_157d_in, absorb(id post) cluster(id comune_id)
	eststo: reghdfe referendum_no_wunsure std_wave_wn_treat_157d_out, absorb(id post) cluster(id comune_id)
	eststo: reghdfe referendum_no_wunsure std_wave_wn_treat_157d_in std_wave_wn_treat_157d_out, absorb(id post) cluster(id comune_id)
	** coefplot:
	coefplot ///
	(est1, ) ///
	(est2, msymbol(S)) ///
	(est3, msymbol(D)) ///
	, ///
	bylabel("{it:referendum result (regional)}") title("{bf:A) bystanders}") ///
	|| ///
	(est4, rename(std_wave_wn_treat_157d_in = std_wn_treat_loc_indoor)) ///
	(est5, msymbol(S) rename(std_wave_wn_treat_157d_out = std_wn_treat_loc_outdoor)) ///
	(est6, msymbol(D) rename(std_wave_wn_treat_157d_in = std_wn_treat_loc_indoor std_wave_wn_treat_157d_out = std_wn_treat_loc_outdoor)) ///
	, ///
	xline(0) ///
	xtitle("OLS coefficient of [...] on {bf:Referendum: No}") ///
	legend(order(2 "indoor" 4 "outdoor" 6 "indoor + outdoor") row(1)) ///
	bylabel("{it:panel survey (individual)}") byopts(xrescale) /// 
	ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) ///
	keep(std_wn_treat_loc_indoor std_wn_treat_loc_outdoor std_wave_wn_treat_157d_in std_wave_wn_treat_157d_out) ///
	ylabel( ///
	1 "M5S: indoor" ///
	2 "M5S: outdoor" ///
	)
	** save figure:
	graph export "$figures/fig7a_bystanders.pdf", as(pdf) name("Graph") replace 
	** save table:
	esttab est* using "$tables/taba11_inout.tex", replace  ///
	indicate( `r(indicate_fe)', labels(\checkmark)) ///
	rename(std_wave_wn_treat_157d_in std_wn_treat_loc_indoor std_wave_wn_treat_157d_out std_wn_treat_loc_outdoor) ///
	se nobaselevels nostar label se(2) b(2) ///
	keep(std_wn_treat_loc_indoor std_wn_treat_loc_outdoor) ///
	stats(N N_clust2 r2_a r2_a_within rmse,  fmt(%9.0f %9.0f %9.2f %9.2f %9.2f) labels("Obs" "Municipalities" "adj.R\$^2$" "adj.R\$^2$ (within)" "RMSE")) ///
	note("\emph{Note:} Clustered standard errors by by province (regional) and individual$\times \$ municipality (individual) in parentheses. All controls omitted from table but same as in the mainbody of the text reported in Table 1 and Table 2.") ///
	substitute(_ _) ///
	mgroups("regional" "individual", pattern( 0 0 0 1 0 0 0 1) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) ///
	span erepeat(\cmidrule(lr){@span})) 




***SUPPORTING INFORMATION***

	use "$data_coded/placebased_regional.dta", clear 

	// using events only instead of RSVPs (tab a3)
	cls
	eststo clear
	eststo: reghdfe referendum_no std_n_treat_campaign, noabsorb cluster(province_id)
	eststo: reghdfe referendum_no std_n_treat_campaign, absorb(province_id) cluster(province_id)   
	eststo: reghdfe referendum_no std_n_treat_campaign `controls', absorb(province_id) cluster(province_id)  
	ebalance m5s_ref_ever `controls'
	eststo: reghdfe referendum_no std_n_treat_campaign [aweight=_webal], absorb(province_id) cluster(province_id)
	***create a LaTeX Table:
	estfe est*, labels(province_id "Province FE")
	*
	esttab est* using "$tables/taba3_events.tex", replace  ///
	indicate( `r(indicate_fe)' "Controls=income", labels(\checkmark)) ///
	se nobaselevels nostar label se(2) b(2) ///
	drop(pd_c_13 turnout_13 unemployment university no_edu foreigners pop_density_16) ///
	stats(N N_clust r2_a r2_a_within rmse, labels("Obs" "Provinces" "adj.R\$^2$" "adj.R\$^2$ (within)" "RMSE")) ///
	note("\emph{Note:} Clustered standard errors by province in parentheses. Controls omitted from table: PD: \% votes 2013, \% turnout 2013, income per cap, \% unemployed, \% university degree, \% low education, \% foreigners, population density. Same variables used for matching, history omitted from matching.") ///
	substitute(_ _) 

	// jackknife provinces (fig a2)
	* estimate: 
	jackknife, cluster(province_id): reghdfe referendum_no m5s_ref_ever `controls', absorb(province_id) cluster(province_id)
	* separately drop provinces: 
	levelsof province_id, local(levels) 
	eststo clear
	foreach l of local levels {
	 eststo pro_`l': reghdfe referendum_no std_wn_treat_campaign `controls' if province_id!=`l', absorb(province_id) cluster(province_id)
	}
	* coefplot:
	
	coefplot pro*, ///
	keep(std_wn_treat_campaign) ///
	vertical ///
	yline(0) pstyle(p1) ///
	legend(off) xlabel("") /// 
	ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) ///
	xtitle("{bf:jackknife:} province (1-110)") ///
	ytitle("OLS coefficient of M5S rsvps on {bf:Referendum: No}") /// 
	addplot(pcarrowi .43 1.275 .37 1.275 (12) "{it:Roma} dropped", mlabel(mlabcolor(uzhred2)) col(uzhred2))

	*save as pdf: 
	graph export "$figures/figa2_jackknife.pdf", replace
	

	// placebo tests (fig a3)
	* estimate: 
	cls 
	eststo clear 
	foreach var of varlist std_wn_postref_m0_m1-std_wn_postref_m11_m12 std_wn_posttreat {
		eststo: reghdfe referendum_no `var' `controls' if m5s_ref_ever==0, absorb(province_id)  cluster(province_id) 
	}
	* coefplot:
	coefplot ///
	(est1, mlabels(std_wn_postref_m0_m1 = 1 "{bf:01/2017}") pstyle(p1)) ///
	(est2, pstyle(p1)) ///
	(est3, pstyle(p1)) ///
	(est4, pstyle(p1)) ///
	(est5, pstyle(p1)) ///
	(est6, pstyle(p1) mlabels(std_wn_postref_m5_m6 = 1 "{bf:06/2017}")) ///
	(est7, pstyle(p1)) ///
	(est8, pstyle(p1)) ///
	(est9, pstyle(p1)) ///
	(est10, pstyle(p1)) ///
	(est11, pstyle(p1)) /// 
	(est12, mlabels(std_wn_postref_m11_m12 = 11 "{bf:12/2017}") pstyle(p1)) ///
	(est13, msymbol(D) mlabels(std_wn_posttreat = 11 "{&sum} 2017") pstyle(p2)) ///
	, rename(std_wn_postref* = postref*) vertical legend(off) ///
	xlabel("") yline(0) ytitle("OLS coefficient of [...] on {bf:Referendum: No}") ///
	drop(_cons `controls') ///
	ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) 
	* save as pdf: 
	graph export "$figures/figa3_placebos.pdf", replace
	
	// different campaign period (tab a4)
	cls
	eststo clear
	eststo: reghdfe referendum_no m5s_ref_ever_short, noabsorb cluster(province_id)
	eststo: reghdfe referendum_no m5s_ref_ever_short, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no m5s_ref_ever_short `controls', absorb(province_id)  cluster(province_id) 
	ebalance m5s_ref_ever_short `controls'
	eststo: reghdfe referendum_no m5s_ref_ever_short [aweight=_webal], absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_treat_campaign_short, noabsorb cluster(province_id)
	eststo: reghdfe referendum_no std_wn_treat_campaign_short, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no std_wn_treat_campaign_short `controls', absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_treat_campaign_short [aweight=_webal], absorb(province_id)  cluster(province_id) 
	** create a LaTeX Table:
	estfe est*, labels(province_id "Province FE")
	** save table: 
	esttab est* using "$tables/taba4_shortercampaign.tex", replace  ///
	indicate( `r(indicate_fe)' "Controls=income", labels(\checkmark)) ///
	se nobaselevels nostar label se(2) b(2) ///
	noconstant nogaps ///
	drop(pd_c_13 turnout_13 unemployment university no_edu foreigners pop_density_16) ///
	stats(N N_clust r2_a r2_a_within rmse, labels("Obs" "Provinces" "adj.R\$^2$" "adj.R\$^2$ (within)" "RMSE") fmt(%9.0f %9.0f %9.2f %9.2f %9.2f)) ///
	note("\emph{Note:} Clustered standard errors by province in parentheses. Controls omitted from table: PD: \% votes 2013, \% turnout 2013, income per cap, \% unemployed, \% university degree, \% low education, \% foreigners, population density. Same variables used for matching, history omitted from matching.") ///
	mgroups("Binary" "Continuous", pattern( 0 0 0 0 1 0 0 0 1) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) ///
	span erepeat(\cmidrule(lr){@span})) ///
	substitute(_ _) 

	// Instrument 

		* internet penetration across time (fig a4)
		project, original("$data_original/internet penetration across time/access_ts.dta")

		use "$data_original/internet penetration across time/access_ts.dta", clear 
		* tw plot: 
		tw connected access year, ///
		xlabel(2007(1)2019) xline(2009) mfcolor(white) mlabel(access) ///
		mlabposition(11) ylab(, nogrid)
		* save as pdf: 
		graph export "$figures/figa4_access_ts.pdf", replace

		* OLS of broadband with UGS distance (fig a5)
		use "$data_coded/placebased_regional.dta", clear 
		* estimate: 
		eststo clear 
		foreach var of varlist adsl12 adsl13 adsl14 adsl15 adsl18 {
			eststo: reghdfe `var' log_ugs, absorb(province_id) cluster(province_id)
		} 
		* coefplot:
		coefplot ///
		(est1,  mlabels(log_ugs = 3 "2012"))  ///
		(est2,  mlabels(log_ugs = 3 "2013"))  ///
		(est3,  mlabels(log_ugs = 3 "2014"))  ///
		(est4,  mlabels(log_ugs = 3 "2015"))  ///
		(est5,  mlabels(log_ugs = 3 "2018"))  ///
		, ///
		keep(log_ugs) vertical ///
		yline(0, lcol(black)) ///
		ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) ///
		legend(off) xlabel("") ///
		ytitle("OLS coefficient of UGS distance on % population with broadband internet") 
		* save as pdf: 
		graph export "$figures/figa5_ugs_adsl.pdf", replace

		* Map of UGS distance (fig a6a)
		use "$data_coded/placebased_mapdata.dta", clear 

		spmap km_to_ugs using "$data_coded/itcoord", ///
		id(id) ocolor(white ..) osize(none ..) ///
		clmethod(c) clbreaks(0 5 6 7 8 9 10 15 20 30 40 50) ///
		fcolor(BuRd) ///
		legtitle("{bf: Distance to closest UGS} {it:(in km)}") legend(pos(7)) legstyle(3) legcount 
		***save as pdf: 
		graph export "$figures/figa6a_ugs.pdf", replace

		* Map of UGS referendum no (fig a6b)
		use "$data_coded/placebased_mapdata.dta", clear 

		spmap referendum_no using "$data_coded/itcoord", ///
		id(id) ocolor(white ..) osize(none ..) ///
		fcolor(BuRd) 
		***save as pdf: 
		graph export "$figures/figa6b_referendum.pdf", replace

		* Testing independence with ITANES 1996 (fig a8)
		use "$data_coded/placebased_independence.dta", clear
		* define controls: 
		global controls age female education unemployed religiosity
		* estimate OLS on variable which might be correlated with internet:
		cls 
		eststo clear
		foreach var of varlist vote96maj_1 vote96maj_2 vote96maj_3 vote96pro_3 vote96pro_5 vote96pro_7 vote96pro_8 lr efficacy_* dem_sat democrat econ_worse econ_worse_personal {
			fre `var'
			rename `var' independence
			eststo: reghdfe independence log_ugs population_2001 [pweight=weight], absorb(province_id) cluster(comune_id)
			rename independence `var'
		}
		* coefplot:
		coefplot ///
		(est1, mlabels(log_ugs = 12 "{bf:Ulivo 1996 (0,1)}") pstyle(p9) msymbol(D)) ///
		(est2, mlabels(log_ugs = 12 "{bf:POL 1996 (0,1)}") pstyle(p6) msymbol(D))  ///
		(est3, mlabels(log_ugs = 1 "{bf:LN 1996 (0,1)}") pstyle(p4) msymbol(D)) ///
		(est4, mlabels(log_ugs = 11 "{bf:PD 1996 (0,1)}") pstyle(p3) msymbol(S)) ///
		(est5, mlabels(log_ugs = 11 "{bf:FI 1996 (0,1)}") pstyle(p1) msymbol(S))  ///
		(est6, mlabels(log_ugs = 11 "{bf:AN 1996 (0,1)}") pstyle(p7) msymbol(S)) ///
		(est7, mlabels(log_ugs = 1 "{bf:LN 1996 (0,1)}") pstyle(p4) msymbol(S)) ///
		(est8, mlabels(log_ugs = 1 "{bf:left-right self (1-5)}") pstyle(p5)) ///
		(est9, mlabels(log_ugs = 11 "{bf:self efficacy (1-4)}") pstyle(p5)) ///
		(est10, mlabels(log_ugs = 11 "{bf:candidates lose touch (1-4)}") pstyle(p5)) ///
		(est11, mlabels(log_ugs = 1 "{bf:candidates not parties relevant (1-4)}") pstyle(p5)) ///
		(est12, mlabels(log_ugs = 1 "{bf:satisfied with demo in Italy (1-4)}") pstyle(p5)) ///
		(est13, mlabels(log_ugs = 1 "{bf:supports democracy (0,1)}") pstyle(p5)) ///
		(est14, mlabels(log_ugs = 1 "{bf:econ Italy worse (0,1)}") pstyle(p5)) ///
		(est15, mlabels(log_ugs = 1 "{bf:econ self worse (0,1)}") pstyle(p5)) ///
		, ///
		keep(log_ugs) ///
		ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) ///
		xline(0)  ///
		grid(none) ///
		legend(off) ///
		ylabel("") ///
		xtitle("OLS coefficients of {bf:UGS distance} on ...")
		* save as pdf: 
		graph export "$figures/figa8_independence.pdf", replace

		* IV placebos (tab a5)
		use "$data_coded/placebased_independence.dta", clear
		cls 
		eststo clear
		foreach var of varlist vote96maj_1 vote96maj_2 vote96maj_3 vote96pro_3 vote96pro_5 vote96pro_7 vote96pro_8 lr efficacy_* dem_sat democrat econ_worse econ_worse_personal {
			*reghdfe `var' log_ugs population_2001, absorb(constant) cluster(comune_id)
			*reghdfe `var' log_ugs population_2001, absorb(province_id) cluster(comune_id)
			eststo: ivreghdfe `var' (std_wn_treat_campaign = c.log_hist##c.log_ugs) population_2001 [pweight=weight], absorb(province_id) cluster(comune_id)
		}
		* create a LaTeX Table:
		estfe est*, labels(province_id "Province FE")
		* save table:
		esttab est* using "$tables/taba5_placebos.tex", replace  ///
		indicate( `r(indicate_fe)' , labels(\checkmark)) ///
		se nobaselevels nostar label se(3) b(3) ///
		stats(N r2_a r2_a_within rmse idstat, labels("\$ Obs$" "\$ adj.R^2$" "\$ adj.R^2 (within)$" "\$ RMSE$" "Kleibergen-Paap" "Cragg-Donald Wald F statistic")) ///
		note("\emph{Note:} clustered standard errors by province") ///
		substitute(_ _) 

		* IV estimates (tab a6)
		use "$data_coded/placebased_regional.dta", clear 
		**instrument 3: internet*early days
		eststo clear
		*eststo: ivreghdfe referendum_no (std_wn_treat_campaign = c.hist_days##c.km_to_ugs), absorb(province_id) cluster(province_id)  first
		eststo: reghdfe referendum_no std_wn_treat_campaign `controls', absorb(province_id)  cluster(province_id) 
				reghdfe std_wn_treat_campaign c.hist_days##c.km_to_ugs population_2001, absorb(province_id) cluster(province_id) 
		eststo: ivreghdfe referendum_no (std_wn_treat_campaign = c.hist_days##c.km_to_ugs) population_2001, absorb(province_id) cluster(province_id) first
		eststo: ivreghdfe referendum_no (std_wn_treat_campaign = c.log_hist##c.log_ugs) population_2001, absorb(province_id) cluster(province_id) first
		eststo: ivreghdfe referendum_no (std_wn_treat_campaign = c.log_hist##c.log_ugs) `controls', absorb(province_id) cluster(province_id) first
		**only ugs distance:
		*eststo: ivreghdfe referendum_no (std_wn_treat_campaign = km_to_ugs), absorb(province_id) cluster(province_id)  first
		eststo: ivreghdfe referendum_no (std_wn_treat_campaign = km_to_ugs) population_2001, absorb(province_id) cluster(province_id)  first
		eststo: ivreghdfe referendum_no (std_wn_treat_campaign = log_ugs) population_2001, absorb(province_id) cluster(province_id)  first
		eststo: ivreghdfe referendum_no (std_wn_treat_campaign = log_ugs) `controls', absorb(province_id) cluster(province_id)  first
		***create a LaTeX Table:
		estfe est*, labels(province_id "Province FE")
		
		esttab est* using "$tables/taba6_instrument.tex", replace  ///
		indicate( `r(indicate_fe)' "Population 2001=population_2001" "Post controls=m5s_c_13", labels(\checkmark)) ///
		se nobaselevels nostar label se(2) b(2) ///
		drop(pd_c_13 turnout_13 income unemployment university no_edu foreigners pop_density_16) ///
		stats(N N_clust rmse widstat, labels("Obs" "Provinces" "RMSE" "Kleibergen-Paap" "Cragg-Donald Wald F statistic")) ///
		mtitles("OLS" "IV: Hist $\times$ UGS" "IV: log(Hist $\times$ UGS)" "IV: log(Hist $\times$ UGS)" "IV: UGS" "IV: log(UGS)" "IV: log(UGS)") ///
		note("\emph{Note:} Clustered standard errors by province in parentheses. Controls omitted from table: M5S: \% votes 2013, PD: \% votes 2013, \% turnout 2013, income per cap, \% unemployed, \% university degree, \% low education, \% foreigners, population density.") ///
		substitute(_ _) 


	// adjacent municipalities (tab a8)
	cls
	eststo clear
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign if std_wn_treat_campaign==0, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign `controls' if std_wn_treat_campaign==0, absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign `controls', absorb(province_id)  cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign std_wn_treat_campaign, absorb(province_id) cluster(province_id)
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign std_wn_treat_campaign `controls', absorb(province_id)  cluster(province_id) 
	***create a LaTeX Table:
	estfe est*, labels(province_id "Province FE")
	*
	esttab est* using "$tables/taba8_adjacent_regional.tex", replace  ///
	indicate( `r(indicate_fe)' "Controls=income", labels(\checkmark)) ///
	se nobaselevels nostar label se(2) b(2) ///
	drop(pd_c_13 turnout_13 unemployment university no_edu foreigners pop_density_16) ///
	stats(N N_clust r2_a r2_a_within rmse, labels("Obs" "Provinces" "adj.R\$^2$" "adj.R\$^2$ (within)" "RMSE")) ///
	note("\emph{Note:} Clustered standard errors by province in parentheses. Controls omitted from table: PD: \% votes 2013, \% turnout 2013, income per cap, \% unemployed, \% university degree, \% low education, \% foreigners, population density. Same variables used for matching, history omitted from matching.") ///
	substitute(_ _) 
	
	// adjacent municipalities (tab a9)
	eststo clear 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign if std_wn_treat_campaign>0, noabsorb cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign `controls' if std_wn_treat_campaign>0, noabsorb cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign if std_wn_treat_campaign>0, absorb(province_id) cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign `controls' if std_wn_treat_campaign>0, absorb(province_id) cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign std_wn_treat_campaign if std_wn_treat_campaign>0, noabsorb cluster(province_id) 
	eststo: reghdfe referendum_no std_wn_neigh_treat_campaign std_wn_treat_campaign `controls' if std_wn_treat_campaign>0, noabsorb cluster(province_id) 
	*eststo: reghdfe referendum_no std_wn_neigh_treat_campaign std_wn_treat_campaign m5s_c_13 pd_c_13 turnout income unemployment university no_edu foreigners pop_density_16 if std_wn_treat_campaign>0, absorb(province_id) cluster(province_id) 
	***create a LaTeX Table:
	estfe est*, labels(province_id "Province FE")
	*
	esttab est* using "$tables/taba9_ONLYadjacent_regional.tex", replace  ///
	indicate( `r(indicate_fe)' "Controls=income", labels(\checkmark)) ///
	se nobaselevels nostar label se(2) b(2) ///
	noconstant nogaps ///
	drop(pd_c_13 turnout_13 unemployment university no_edu foreigners pop_density_16) ///
	stats(N N_clust r2_a r2_a_within rmse, labels("Obs" "Provinces" "adj.R\$^2$" "adj.R\$^2$ (within)" "RMSE") fmt(%9.0f %9.0f %9.2f %9.2f %9.2f)) ///
	note("\emph{Note:} Clustered standard errors by province in parentheses. Controls omitted from table: PD: \% votes 2013, \% turnout 2013, income per cap, \% unemployed, \% university degree, \% low education, \% foreigners, population density. Same variables used for matching, history omitted from matching.") ///
	substitute(_ _) 
	

	// effect of M5S on other referendum outcomes, Yes + Turnout (fig a10)
	cls
	eststo clear
	foreach var of varlist referendum_yes turnout {
		eststo: reghdfe `var' std_wn_treat_campaign, noabsorb cluster(province_id)
		eststo: reghdfe `var' std_wn_treat_campaign, absorb(province_id) cluster(province_id)
		eststo: reghdfe `var' std_wn_treat_campaign `controls', absorb(province_id)  cluster(province_id) 
		ebalance m5s_ref_ever `controls'
		eststo: reghdfe `var' std_wn_treat_campaign [aweight=_webal], absorb(province_id) cluster(province_id)
	}

	*
	coefplot ///
	est1 est2 est3 est4, legend(off) bylabel("{bf:Referendum: 'Yes'}")  ///
	|| ///
	est5 est6 est7 est8,    /// 
	drop(_cons) ///
	ciopts(lwidth(0.4 ..)) mlwidth(medthick) msize(medsmall) mfcolor(white) ///
	byopts(legend(off)) ///
	bylabel("{bf:Referendum: turnout}") ///
	xline(0)  ///
	grid(none) ///
	ylabel( ///
	1 "{bf:M5S: referendum}" ///
	2 "M5S: % votes 2013" ///
	3 "PD: % votes 2013" ///
	4 "% turnout 2013" ///
	5 "income per cap" ///
	6 "% unemployed"  ///
	7 "% university" ///
	8  "% low education" ///
	9 "% foreigners" /// 
	10 "population density" /// 
	)
	* save as pdf: 
	graph export "$figures/figa10_ty_regional.pdf", replace

	// Indoor vs. Outdoor (Fig a12)
	summarize wn_treat_loc_indoor if wn_treat_loc_indoor>0
	local m_in=r(mean)
	local m_in=round(`m_in', 0.01)
	summarize wn_treat_loc_outdoor if wn_treat_loc_outdoor>0
	local m_out=r(mean)
	local m_out=round(`m_out', 0.01)
	* histogram:
	histogram wn_treat_loc_indoor if wn_treat_loc_indoor>0, ///
	col(uzhblue%50) xtitle("RSVPs for ...") legend(order(1 "indoor" 2 "outdoor")) ///
	addplot(histogram wn_treat_loc_outdoor if wn_treat_loc_outdoor>0, col(uzhred2%50)) ///
	xline(`m_in', lcol(uzhblue)) xline( `m_out', lcol(uzhred2)) ///
	text(0 `m_in' " `m_in' ", place(e) col(uzhblue) size(small)) text(0  `m_out' " `m_out' ", place(w) col(uzhred2) size(small))
	* save as pdf: 
	graph export "$figures/figa12_inout.pdf", replace


	// Indoor vs. Outdoor (Fig a13)
	summarize n_treat_loc_indoor if n_treat_loc_indoor>0
	local m_in=r(mean)
	local m_in=round(`m_in', 0.01)
	summarize n_treat_loc_outdoor if n_treat_loc_outdoor>0
	local m_out=r(mean)
	local m_out=round(`m_out', 0.01)
	* histogram: 
	histogram n_treat_loc_indoor if n_treat_loc_indoor>0, ///
	col(uzhblue%50) xtitle("Events ...") legend(order(1 "indoor" 2 "outdoor")) ///
	addplot(histogram n_treat_loc_outdoor if n_treat_loc_outdoor>0, col(uzhred2%50)) ///
	xline(`m_in', lcol(uzhblue)) xline( `m_out', lcol(uzhred2)) ///
	text(0 `m_in' " `m_in' ", place(e) col(uzhblue) size(small)) text(0  `m_out' " `m_out' ", place(w) col(uzhred2) size(small))
	* save as pdf: 
	graph export "$figures/figa13_inout.pdf", replace
	** create a LaTeX Table:
	estfe est*, labels(post "Wave FE" comune_id "Municipality FE" province_id "Province FE")

	// summary statistics (tab a12) 
	est clear  
	
	estpost tabstat referendum_no m5s_ref_ever std_wn_treat_campaign ///
	`controls' ///
	std_wn_treat_campaign_short std_wn_neigh_treat_campaign  km_to_ugs hist_days std_wn_posttreat std_wn_treat_loc_indoor std_wn_treat_loc_outdoor ///
	, ///
	c(stat) stat(mean sd min max n)
	
	esttab using "$tables/taba12_summary_regional.tex", replace ///
	cells("mean(fmt(%13.2fc)) sd(fmt(%13.2fc)) min max count") nonumber ///
	nomtitle nonote noobs label collabels("Mean" "SD" "Min" "Max" "N")

